﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using App.Core.Extensions;
using App.Data;

public partial class Pages_Public_ShowContent : BasePage
{
    private int _ContentID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        BindPageInfo();
        if (!IsPostBack)
        {
            BindContentInfo();
        }
    }
    protected void BindPageInfo()
    {
        _ContentID = WebUtil.GetQueryStringInInt(AppConstants.QueryString.ID);
        Page.Title = WebUtil.GetPageTitle(h4Heding.InnerHtml);
    }
    protected void BindContentInfo()
    {
        BtcHousingEntities context = new BtcHousingEntities();
        var content = context.Contents.FirstOrDefault(P => P.ID == _ContentID);
        if (content == null)
            ShowNotFoundMessage();
        else
        {
            h4Heding.InnerHtml = content.Title.HtmlEncode();
            ltrContentDetails.Text = content.Description; //WebUtil.FormatText(content.Description);
            Page.Title = WebUtil.GetPageTitle(h4Heding.InnerHtml);

            ///Check for About US
            if (content.ID == ConfigReader.ContentIDOfAboutUs)
            {
                Control control = this.Master.FindControl("ucSidebarAdvertisement");
                if (control != null)
                    control.Visible = false;
            }
        }
    }
    protected void ShowNotFoundMessage()
    {
        WebUtil.ShowMessageBox(divMessage, "Sorry! the requested content was not found.", true);
    }
}